---@装饰器  请求网关统一校验，插件动态架子啊配置
local _auth = class("AuthDecorator")
--======================================
--default params
local d = Ding
local Logger = d.Logger
--======================================
local PLUGIN_LIST = {   
    "base_auth"     --todo 插件动态加载
}


local EXPORTED_METHODS = {
    "gateway_api_chk_"
}

function _gw:init_()
    self._plugins = {}
end

function _gw:bind()
    self:init_()
    d.setmethods(target, self, EXPORTED_METHODS)
end

function _gw:unbind(target)
    d.unbind(target, EXPORTED_METHODS)
end

function _gw:api_chk(uri, reqdata)
    local ret = true
    for _, plugin in PLUGIN_LIST do 
        if not self._plugins[plugin] then 
            self._plugins[plugin] = 1 -- pmloader:load(plugin)
        end
        ret = ret and func_hook(self._plugins["plugin"],"api_chk")
        if not (ret) then 
            return false
        end
    end
    return ret
end


return _gw
